#!/bin/sh

mkdir -p tmp
TMP_DIR=tmp
OUTPUT_DIR=tmp

OLD=reglookup-recover
NEW=../trunk/build/bin/reglookup-recover


compareOneFile()
{
  echo "Comparing output on $BNAME, test case: $CASE" 1>&2

  echo "  $OLD $OPTS $F" 1>&2
  $OLD $OPTS $F > $TMP_DIR/old.csv

  echo "  $NEW $OPTS $F" 1>&2
  $NEW $OPTS $F > $TMP_DIR/new.csv

  diff -ud $TMP_DIR/old.csv $TMP_DIR/new.csv > $OUTPUT_DIR/$CASE-${BNAME}.diff  
  SIZE=`stat -c '%s' $OUTPUT_DIR/$CASE-${BNAME}.diff`
  if [ "x$SIZE" = "x0" ]; then
    rm $OUTPUT_DIR/$CASE-${BNAME}.diff
  fi
}

for F in hives/*; do
{

  BNAME=`basename $F`

  CASE=basic
  OPTS=''
  compareOneFile

  CASE=raw
  OPTS='-r'
  compareOneFile
} done

rm $TMP_DIR/old.csv $TMP_DIR/new.csv
